/**
 * @file router
 * @author: vscode
 * @Date: 2018-10-23 22:35:06
 * @Last Modified by: v_xieyejiang
 * @Last Modified time: 2018-12-10 14:22:37
 */

'use strict';

const user = require('../controllers/user');
const common = require('../controllers/common');
const notice = require('../controllers/notice');
const uuap = require('../controllers/uuap');
const setRes = require('../utils/setRes');
const packageConf = require('../../package.json');
const prefix = packageConf.prefix;

module.exports = app => {
    /**
     * hello
     */
    app.get(`${prefix}hello`, (req, res) => {
        setRes(res, 200, {message: 'hello'});
    });
    app.post(`${prefix}hello`, (req, res) => {
        setRes(res, 200, {message: 'hello'});
    });
    /**
     * 以下有排名顺序
     * uuap
     */
    app.get(`${prefix}logout`, uuap.logout);
    app.all(`${prefix}*`, uuap.auth);
    /**
     * user
     */
    app.get(`${prefix}userInfo`, user.userInfo);
    /**
     * custom
     */
    // global-notice
    app.get(`${prefix}notice/read`, notice.read);
    app.get(`${prefix}notice/write`, notice.write);

    /**
     * 最底部
     * public
     */
    app.get(`${prefix}*`, common.getMethods);
    app.post(`${prefix}*`, common.postMethods);
};
